package net.wanho.shop.service.impl;

import lombok.RequiredArgsConstructor;
import net.wanho.shop.mapper.GoodsMapper;
import net.wanho.shop.mapper.MemberMapper;
import net.wanho.shop.mapper.OrderMapper;
import net.wanho.shop.mapper.ReportMapper;
import net.wanho.shop.service.ReportService;
import net.wanho.shop.vo.OrderStatusVo;
import net.wanho.shop.vo.PayMethodVo;
import net.wanho.shop.vo.ReportVo;
import net.wanho.shop.vo.TopTenVo;
import net.wanho.shop.vo.TurnoverVo;
import org.springframework.stereotype.Service;

/**
 * 这个类是：
 *
 * @author: MENG HU WANG
 * @date: 2024/12/31 0:52
 * @version: 1.0
 */

@Service
@RequiredArgsConstructor
public class ReportServiceImpl implements ReportService {

    private final MemberMapper memberMapper;
    private final GoodsMapper goodsMapper;
    private final OrderMapper orderMapper;
    private final ReportMapper reportMapper;

    @Override
    public ReportVo live() {
        ReportVo reportVo = new ReportVo();
        int memberCount = memberMapper.selectCount();
        int goodsCount = goodsMapper.selectCount();
        int orderCount = orderMapper.selectCount();
        Double salesAmount = orderMapper.selectSalesAmount();


        reportVo.setMemberCount(memberCount);
        reportVo.setGoodsCount(goodsCount);
        reportVo.setOrderCount(orderCount);
        reportVo.setSalesAmount(salesAmount);
        return reportVo;

    }

    @Override
    public TurnoverVo getTurnover() {
        return reportMapper.selectTurnover();
    }

    @Override
    public OrderStatusVo getOrderStatus() {
        return reportMapper.selectOrderStatus();
    }

    @Override
    public TopTenVo getTopTen() {
        return reportMapper.selectTopTen();
    }

    @Override
    public PayMethodVo getPayMethod() {
        return reportMapper.selectGetMethods();
    }
}
